# _*_ coding:utf-8 _*_
# @Time : 2023/5/25 17:57
# @Author : wsl
# @File : day05_demo
# @Project : python  案例https://blog.csdn.net/luxideyao/article/details/77802389
import json
import jsonpath

obj = json.load(open('store.json', 'r', encoding='utf-8'))
author_list = jsonpath.jsonpath(obj, '$.store.book[*].author')
author_list = jsonpath.jsonpath(obj, '$.store.book[2].author')
author_list = jsonpath.jsonpath(obj, '$..author')
price_list = jsonpath.jsonpath(obj, '$.store..price')
book = jsonpath.jsonpath(obj, '$..book[2]')
book = jsonpath.jsonpath(obj, '$..book[(@.length-1)]')
book = jsonpath.jsonpath(obj, '$..book[0,1]')
book = jsonpath.jsonpath(obj, '$..book[:2]')
book = jsonpath.jsonpath(obj, '$..book[?(@.isbn)]')
book = jsonpath.jsonpath(obj, '$..book[?(@.price<10)]')

print(book)
